---
title: 'Quickstart: contributing'
description: 'Learn how to preview changes locally'
---

## Setup Local Environment

<Info>
  **Prerequisite** You should have installed Node.js (version 18.10.0 or
  higher).
</Info>

Step 1. Install `pnpm` on your OS:

<CodeGroup>

```bash npm
npm install -g pnpm
```

```bash brew
brew install pnpm
```

```l other
https://pnpm.io/installation
```

</CodeGroup>



Step 2. Add the required environment variables:

- Go to `/[root]/CopilotKit/examples/next-openai/` 
- Duplicate `.env.local.example`, name the duplicate `.env.local`
- Edit `.env.local` with approrpriate values


Step 3. Recursively install & build all dependencies:

In `/[root]/CopilotKit` run:
```bash
pnpm -w freshbuild
```

Step 4. Run all packages & the example app in dev mode, to automatically load changes on file save.

Please Note!\
If you save files in a file that's part of the example app, the app will hot-load the changes automatically.
But if you make changes in a **package**, you first have to go to a file of the example app, and re-save it,
for the package changes to propagate into the running app.

In `/[root]/CopilotKit/` run:
```bash
pnpm run dev
```

By default the app will run on `http://localhost:3000`, however if 3000 is already taken, it will try other available ports sequentially.
To see which port was chosen, look in the output logs for something like

```bash
next-openai:dev: - ready started server on 0.0.0.0:3002, url: http://localhost:3002
```

## Testing your solution
Before submitting a pull request, please run the following locally:

1. Lint your code:
`pnpm -w format`

2. Make sure there are no build errors:
`pnpm -w freshbuild`

3. Make sure tests are passing
`pnpm run test`

## Troubleshooting

Here's how to solve some common problems when working with the CLI.

<AccordionGroup>
  <Accordion title="npm is giving errors">
    You need to use `pnpm`, not `npm`. See above.
  </Accordion>
  <Accordion title="Unclear build error">
Make sure you have specified the environment variables in `.env.local` as above.
  </Accordion>
  <Accordion title="Package changes not taking affect in example app">
    You can always try to clean and rebuild, by running `pnpm -w freshbuild` from the `[root]/CopilotKit` directory.
  </Accordion>
</AccordionGroup>

Need support? Check out the [#contributing](https://discord.gg/6dffbvGU3D) channel in the [Discord](https://discord.gg/6dffbvGU3D).